<template>
	<view>
		<view class='order-details'>
			<orderGoods :evaluate='evaluate' :productType="orderInfo.type" :orderId="order_id" :ids="id" :uniId="uniId"
				:cartInfo="orderInfo" :jump="true"></orderGoods>
			<!-- 给header上与data上加on为退款订单-->

			<view class="">
				<view class='header bg-color' v-if="orderInfo.shippingType == 1" :class='isGoodsReturn ? "on":""'>
					<view class="selfInfo-msg-left1" style="color: #F05208;">{{orderInfo.orderStatusMsg}}</view>
					<!-- <view class='picTxt acea-row row-middle'>
						<view class='pictrue' v-if="isGoodsReturn==false">
							<image :src="orderInfo.statusPic"></image>
						</view>
						<view class='data' :class='isGoodsReturn ? "on":""'>
							<view class='state'>{{orderInfo.orderStatusMsg}}</view>
							<view>{{orderInfo.createTime}}</view>
						</view>
					</view> -->
					<view class='address borRadius14'>
						<view class='name'>{{orderInfo.realName}}<text class='phone'>{{orderInfo.userPhone}}</text>
						</view>
						<view>{{orderInfo.userAddress}}</view>
					</view>
					<!-- <view v-else class='address' style="margin-top:15rpx;">
						<view class='name' @tap="makePhone">{{orderInfo.systemStore?orderInfo.systemStore.name:''}}<text
								class='phone'>{{orderInfo.systemStore?orderInfo.systemStore.phone:''}}</text><text
								class="iconfont icon-tonghua font-color"></text></view>
						<view>{{orderInfo.systemStore?orderInfo.systemStore.detailedAddress:''}}</view>
					</view> -->
				</view>
				<view class="selfInfo pad30" v-if="orderInfo.shippingType==2">
					<view class="selfInfo-wrap">
						<view class="selfInfo-msg dis">
							<view class="selfInfo-msg-left">
								<view class="selfInfo-msg-left1">{{orderInfo.orderStatusMsg}}</view>
								<view class="selfInfo-msg-left2">到店提货时间:{{orderInfo.takeTime}}</view>
								<view class="selfInfo-msg-left3">自提点：{{orderInfo.systemStore.introduction}}</view>
								<view class="selfInfo-msg-left4">营业时间：{{orderInfo.systemStore.dayTime}}
								</view>

							</view>
							<view class="selfInfo-msg-ritght">
								<view class="selfInfo-msg-ritght1" @click="lookBigImg()">
									<!-- <image :src="codeImg"></image> -->

									<canvas v-if="isLookBigImg" canvas-id="qrcode" style="margin: 0 auto;"
										:style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" />
								</view>
								<view class="selfInfo-msg-ritght2">提货码：{{qrcodeText}}</view>
							</view>
						</view>
						<view class="selfInfo-msg dis">

							<view class="selfInfo-msg-left selfInfo-msg-lefts dis"
								@click="call(orderInfo.systemStore.phone)">
								<image class="image_2" src="@/static/pagesA/icon_dt.png" mode=""></image>

								<text class="text-group_3">联系自提点</text>
							</view>
							<view class="selfInfo-msg-ritght selfInfo-msg-lefts dis"
								@click="openLocation(orderInfo.systemStore)">

								<image class="image_2" src="@/static/pagesA/icon_dh.png" mode=""></image>
								<text class="text-group_3">导航到自提点</text>
							</view>

						</view>
					</view>




				</view>
				<!-- v-if="orderInfo.shippingType === 1" -->
				<!-- <view class='address borRadius14' style="margin: 20rpx 0;">
					<view class='name'>{{orderInfo.realName}}<text class='phone'>{{orderInfo.userPhone}}</text>
						<text style="color: #F05208;margin-left: 100rpx;">代取减</text>
					</view>
					<view>{{orderInfo.userAddress}}</view>
				</view> -->
				<view class="selfInfo-pro" v-if="orderInfo.shippingType==1||orderInfo.shippingType==2">
					<view class="index-coupon">
						<view class="index-coupon-view">
							<view class="index-coupon-msg" v-for="(item,index) in orderInfo.orderInfoList" :key="index">
								<view class="index-coupon-msg-wrap">
									<view class="index-coupon-msg-left">
										<image :src="item.image" mode=""></image>

									</view>

									<view class="index-coupon-msg-center">
										<view class="index-coupon-msg-center-up">{{item.storeName}}</view>
										<view class="index-coupon-msg-center-bom">
											{{item.takeDesc}}
										</view>
									</view>

								</view>

							</view>
						</view>
					</view>
				</view>
				<view v-if="isGoodsReturn==false" class="pad30">
					<view class='nav' v-if="false">
						<view class='navCon acea-row row-between-wrapper'>
							<view :class="!orderInfo.paid ? 'on':''">待付款</view>
							<view :class="orderInfo.paid && orderInfo.status == 0 ? 'on':''">
								{{orderInfo.shippingType==1 ? '待发货':'待核销'}}
							</view>
							<view :class="orderInfo.status == 1 ? 'on':''" v-if="orderInfo.shippingType == 1">待收货</view>
							<view :class="orderInfo.status == 2 ? 'on':''">待评价</view>
							<view :class="orderInfo.status == 3 ? 'on':''">已完成</view>
						</view>
						<view class='progress acea-row row-between-wrapper'>
							<view class='iconfont'
								:class='(!orderInfo.paid ? "icon-webicon318":"icon-yuandianxiao") + " " + ( orderInfo.paid ? "font-color":"")'>
							</view>
							<view class='line' :class='orderInfo.paid > 0 ? "bg-color":""'></view>
							<view class='iconfont'
								:class='(orderInfo.status == 0 ? "icon-webicon318":"icon-yuandianxiao") + " " + (orderInfo.status >= 0 ? "font-color":"")'>
							</view>
							<view class='line' :class='orderInfo.status > 0 ? "bg-color":""'
								v-if="orderInfo.shippingType == 1"></view>
							<view class='iconfont'
								:class='(orderInfo.status == 1 ? "icon-webicon318":"icon-yuandianxiao") + " " +(orderInfo.status >= 1 ? "font-color":"")'
								v-if="orderInfo.shippingType == 1"></view>
							<view class='line' :class='orderInfo.status > 1 ? "bg-color":""'></view>
							<view class='iconfont'
								:class='(orderInfo.status == 2 ? "icon-webicon318":"icon-yuandianxiao") + " " + (orderInfo.status >= 2 ? "font-color":"")'>
							</view>
							<view class='line' :class='orderInfo.status > 2 ? "bg-color":""'></view>
							<view class='iconfont'
								:class='(orderInfo.status == 3 ? "icon-webicon318":"icon-yuandianxiao") + " " + (orderInfo.status >= 3 ? "font-color":"")'>
							</view>
						</view>
					</view>
					<view v-if="false" class="writeOff borRadius14">
						<view class="title">核销信息</view>
						<view class="grayBg">
							<view class="pictrue">
								<!-- <div class="qrcode" ref="qrcode"></div> -->
								<!-- <canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}100%`, height: `${qrcodeSize}100%`}"/> -->
								<image :src="codeImg"></image>
							</view>
						</view>
						<view class="gear">
							<image src="../../static/images/writeOff.jpg"></image>
						</view>
						<view class="num">{{orderInfo.verifyCode}}</view>
						<view class="rules" v-if='orderInfo.systemStore'>
							<view class="item">
								<view class="rulesTitle acea-row row-middle">
									<text class="iconfont icon-shijian"></text>核销时间
								</view>
								<view class="info">
									每日：<text class="time">{{orderInfo.systemStore.dayTime.replace(',','-')}}</text>
								</view>
							</view>
							<view class="item">
								<view class="rulesTitle acea-row row-middle">
									<text class="iconfont icon-shuoming1"></text>使用说明
								</view>
								<view class="info">可将二维码出示给店员扫描或提供数字核销码</view>
							</view>
						</view>
					</view>
					<view v-if="false" class="map acea-row row-between-wrapper borRadius14">
						<view>自提地址信息</view>
						<view class="place cart-color acea-row row-center-wrapper" @tap="showMaoLocation">
							<text class="iconfont icon-weizhi"></text>查看位置
						</view>
					</view>



					<!-- #ifndef MP -->
					<!-- <div class="goodCall borRadius14" @click="kefuClick">
						<span class="iconfont icon-kefu"></span><span>联系客服</span>
					</div> -->
					<!-- #endif -->
					<!-- #ifdef MP -->
					<!-- <div class="goodCall borRadius14">
						<button open-type='contact' hover-class='none'>
							<span class="iconfont icon-kefu"></span><span>联系客服</span>
						</button>
					</div> -->
					<!-- #endif -->
				</view>

				<view class="pad30" v-if="orderInfo.shippingType==1||orderInfo.shippingType==2">
					<view class='nav refund' v-if="orderInfo.refundStatus>0">
						<view class="title">
							<image src="/static/images/shuoming.png" mode=""></image>
							{{orderInfo.refundStatus==1?'商家审核中':orderInfo.refundStatus==2?'商家已退款':'商家拒绝退款'}}
						</view>
						<view class="con pad30">
							{{orderInfo.refundStatus==1 ? "您已成功发起退款申请，请耐心等待商家处理；退款前请与商家协商一致，有助于更好的处理售后问题": orderInfo.refundStatus==2? "退款已成功受理，如商家已寄出商品请尽快退回；感谢您的支持": "拒绝原因：" + orderInfo.refundReason}}
						</view>
					</view>
					<view class='wrapper borRadius14'>
						<view class='item acea-row row-between'>
							<view>订单编号：</view>
							<view class='conter acea-row row-middle row-right'>{{orderInfo.orderId}}
								<!-- #ifndef H5 -->
								<text class='copy' @tap='copy(orderInfo.orderId)'>复制</text>
								<!-- #endif -->
								<!-- #ifdef H5 -->
								<text class='copy copy-data' :data-clipboard-text="orderInfo.orderId">复制</text>
								<!-- #endif -->
							</view>
						</view>
						<view class='item acea-row row-between'>
							<view>子订单编号：</view>
							<view class='conter acea-row row-middle row-right'>{{orderInfo.subOrderId||'暂无'}}
								<!-- #ifndef H5 -->
								<text class='copy' @tap='copy(orderInfo.subOrderId)'>复制</text>
								<!-- #endif -->
								<!-- #ifdef H5 -->
								<text class='copy copy-data' :data-clipboard-text="orderInfo.subOrderId">复制</text>
								<!-- #endif -->
							</view>
						</view>
						<view class='item acea-row row-between'>
							<view>申请提货时间：</view>
							<view class='conter acea-row row-middle row-right'>{{orderInfo.createTime}}
								<!-- #ifndef H5 -->
								<!-- <text class='copy' @tap='copy'>复制</text> -->
								<!-- #endif -->
								<!-- #ifdef H5 -->
								<!-- <text class='copy copy-data' :data-clipboard-text="orderInfo.orderId">复制</text> -->
								<!-- #endif -->
							</view>
						</view>


						<view class='item acea-row row-between'>
							<view>下单时间：</view>
							<view class='conter'>{{(orderInfo.createTime || 0)}}</view>
						</view>
						<view class='item acea-row row-between'>
							<view>支付状态：</view>
							<view class='conter' v-if="orderInfo.paid">已支付</view>
							<view class='conter' v-else>未支付</view>
						</view>
						<view class='item acea-row row-between'>
							<view>支付方式：</view>
							<view class='conter'>{{orderInfo.payTypeStr}}</view>
						</view>
						<view class='item acea-row row-between' v-if="orderInfo.mark">
							<view>买家留言：</view>
							<view class='conter'>{{orderInfo.mark}}</view>
						</view>
					</view>
					<!-- 退款订单详情 "-->
					<view v-if="isGoodsReturn" class='wrapper borRadius14'>
						<view class='item acea-row row-between'>
							<view>收货人：</view>
							<view class='conter'>{{orderInfo.realName}}</view>
						</view>
						<view class='item acea-row row-between'>
							<view>联系电话：</view>
							<view class='conter'>{{orderInfo.userPhone}}</view>
						</view>
						<view class='item acea-row row-between'>
							<view>收货地址：</view>
							<view class='conter'>{{orderInfo.userAddress}}</view>
						</view>
					</view>
					<view v-if="orderInfo.status>0">
						<view class='wrapper borRadius14' v-if='orderInfo.deliveryType=="express"'>
							<view class='item acea-row row-between'>
								<view>配送方式：</view>
								<view class='conter' v-if="orderInfo.shippingType==0">未配送</view>
								<view class='conter' v-if="orderInfo.shippingType==1">物流配送</view>
								<view class='conter' v-if="orderInfo.shippingType==2">自提点提货</view>
								<!-- <view class='conter'>发货</view> -->
							</view>
							<view class='item acea-row row-between'>
								<view>快递公司：</view>
								<view class='conter'>{{orderInfo.deliveryName || ''}}</view>
							</view>
							<view class='item acea-row row-between'>
								<view>快递号：</view>
								<view class='conter'>{{orderInfo.deliveryId || ''}}</view>
							</view>
						</view>
						<view class='wrapper borRadius14' v-else-if='orderInfo.deliveryType=="send"'>
							<view class='item acea-row row-between'>
								<view>配送方式：</view>
								<view class='conter' v-if="orderInfo.shippingType==0">未配送</view>
								<view class='conter' v-if="orderInfo.shippingType==1">物流配送</view>
								<view class='conter' v-if="orderInfo.shippingType==2">自提点提货</view>

							</view>
							<view class='item acea-row row-between'>
								<view>配送人姓名：</view>
								<view class='conter'>{{orderInfo.deliveryName || ''}}</view>
							</view>
							<view class='item acea-row row-between'>
								<view>联系电话：</view>
								<view class='conter acea-row row-middle row-right'>{{orderInfo.deliveryId || ''}}<text
										class='copy' @tap='goTel'>拨打</text></view>
							</view>
						</view>
						<view class='wrapper borRadius14' v-else-if='orderInfo.deliveryType=="fictitious"'>
							<view class='item acea-row row-between'>
								<view>虚拟发货：</view>
								<view class='conter'>已发货，请注意查收</view>
							</view>
						</view>
					</view>
					<view class='wrapper borRadius14'>
						<view class='item acea-row row-between'>
							<view>商品总价：</view>
							<view class='conter'>￥{{orderInfo.proTotalPrice}}</view>
						</view>
						<view class='item acea-row row-between' v-if="orderInfo.payPostage > 0">
							<view>运费：</view>
							<view class='conter'>￥{{orderInfo.payPostage}}</view>
						</view>
						<view class='item acea-row row-between' v-if='orderInfo.couponId'>
							<view>优惠券抵扣：</view>
							<view class='conter'>-￥{{orderInfo.couponPrice}}</view>
						</view>
						<view class='item acea-row row-between' v-if="orderInfo.useIntegral > 0">
							<view>积分抵扣：</view>
							<view class='conter'>-￥{{orderInfo.deductionPrice}}</view>
						</view>
						<view class='actualPay acea-row row-right'>实付款：<text
								class='money font-color'>￥{{orderInfo.payPrice}}</text></view>
					</view>
					<!-- <view style='height:120rpx;'></view> -->
					<view class='footer acea-row row-right row-middle'>

						<view class="qs-btn" v-if="!orderInfo.paid" @click.stop="cancelOrder">取消订单</view>
						<view class='bnt bg-color' v-if="!orderInfo.paid" @tap='pay_open(orderInfo.orderId)'>立即付款</view>
						<!-- #ifdef MP -->

						<view @tap="openSubcribe()" class='bnt cancel'
							v-else-if="orderInfo.paid === true&&!orderInfo.subOrderId && orderInfo.refundStatus === 0 && orderInfo.type!==1 && type==='normal'">
							申请退款
						</view>
						<!-- #endif -->
						<!-- #ifndef MP -->
						<navigator hover-class="none"
							:url="'/pages/users/goods_return/index?orderId='+orderInfo.orderId" class='bnt cancel'
							v-else-if="orderInfo.paid === true && orderInfo.refundStatus === 0 && orderInfo.type!==1 && type==='normal'">
							申请退款
						</navigator>
						<!-- #endif -->
						<view class='bnt bg-color' v-if="orderInfo.combinationId > 0" @tap='goJoinPink'>查看拼团</view>
						<navigator class='bnt cancel' v-if="orderInfo.deliveryType == 'express' && orderInfo.status >0"
							hover-class='none' :url="'/pages/users/goods_logistics/index?orderId='+ orderInfo.orderId">
							查看物流
						</navigator>
						<view class='bnt bg-color' v-if="orderInfo.status==1" @tap='confirmOrder'>确认收货</view>
						<view class='bnt cancel' v-if="orderInfo.status==3" @tap='delOrder'>删除订单</view>
						<view class='bnt bg-color' v-if="orderInfo.status==3 && orderInfo.type!==1"
							@tap='goOrderConfirm'>再次购买</view>
					</view>

				</view>


			</view>
			<view class="wrapp" v-if="orderInfo.shippingType == 0">
				<view class="titiles ">
					<view class="titiles-up dis">
						<view class="titiles-up-left">
							认养有效期截止时间:{{orderInfo.createTime}}
						</view>
						<view class="titiles-up-right" v-if="orderInfo.showTake"
							@click="goPage('/pagesB/fosterOrder/pikeUp/index?order_id=' + orderInfo.orderId)">
							申请提货
						</view>
					</view>

				</view>
				<view class="block_4 block_41 flex-row dis" v-for="(item,index) in orderInfo.orderInfoList"
					:key="index">

					<image class="image_2" referrerpolicy="no-referrer" src="../../../static/logo.png" />
					<view class="box_6 flex-col">
						<view class="text_6 dis justify-between">
							<view class="line1">产品名称:{{item.storeName}}</view>
							<view>剩余：{{item.yieldNum}}</view>
						</view>
						<view v-if="item.type == 0">
								<view class="text_6">产量:{{item.yield}}</view>
						</view>
						<view v-if="item.type == 7 || item.type== 8">
								<view class="text_6">数量:{{item.yield}}</view>
						</view>
						<view v-if="null != item.getDay">
							<view class="text_6">可提货时间:{{item.getDay}}</view>
							<view class="box_7 flex-row dis">
								<view class="text_9">生长进度:</view>
								<view class="group_1 dis">
									<progress style="width: 67%;" :percent="item.process" border-radius="30" show-info
										stroke-width="6" />
									<view class="">
										{{item.processDesc}}
									</view>
							
								</view>
								<!-- <view class="text_10">
									<uni-number-box :min="0" :max="item.yieldNum" v-model="vModelValue" />
								</view> -->
							</view>
						</view>
						
					</view>
				</view>
				<view class='wrapper borRadius14'>
					<view class='item acea-row row-between'>
						<view>商品总价：</view>
						<view class='conter'>￥{{orderInfo.proTotalPrice}}</view>
					</view>
					<!-- v-if="orderInfo.payPostage > 0" -->
					<!-- <view class='item acea-row row-between'>
						<view>运费：</view>
						<view class='conter'>￥{{orderInfo.payPostage}}</view>
					</view> -->
					<!-- v-if='orderInfo.couponId' -->
					<view class='item acea-row row-between'>
						<view>优惠券抵扣：</view>
						<view class='conter'>-￥{{orderInfo.couponPrice}}</view>
					</view>
					<!-- v-if="orderInfo.useIntegral > 0" -->
					<!-- 	<view class='item acea-row row-between'>
						<view>积分抵扣：</view>
						<view class='conter'>-￥{{orderInfo.deductionPrice}}</view>
					</view> -->
					<view class='item acea-row row-between'>
						<view>所属地块：</view>
						<view class='conter dis' style="align-items: center;" @click="goDk()">
							查看地块分布
							<image style="width: 30rpx;height: 30rpx;" src="@/static/com/icon_more.png" mode=""></image>
						</view>
					</view>
					<view class='item acea-row row-between'>
						<view>下单时间：</view>
						<view class='conter'>{{orderInfo.payTime}}</view>
					</view>
					<view class='item acea-row row-between'>
						<view>认养证书：</view>
						<view class='conter' style="color: #46B681;" @click="lookGrtificates">查看</view>
					</view>
					<!-- <view class='item acea-row row-between'>
						<view>优惠券抵扣：</view>
						<view class='conter'>-￥{{orderInfo.couponPrice}}</view>
					</view> -->

					<view class='actualPay acea-row row-right'>实付款：
						<text class='money font-color'>￥{{orderInfo.payPrice}}</text>
					</view>

				</view>
				<view class='footer acea-row row-right row-middle'>

					<view class="qs-btn" v-if="!orderInfo.paid" @click.stop="cancelOrder">取消订单</view>
					<view class='bnt bg-color' v-if="!orderInfo.paid" @tap='pay_open(orderInfo.orderId)'>立即付款</view>
					<!-- #ifdef MP -->
					<view @tap="openSubcribe()" class='bnt cancel'
						v-else-if="orderInfo.paid === true && orderInfo.refundStatus === 0 && orderInfo.type!==1 && type==='normal'&&orderInfo.refund_lag==true">
						申请退款
					</view>
					<!-- #endif -->
					<!-- #ifndef MP -->
					<navigator hover-class="none" :url="'/pages/users/goods_return/index?orderId='+orderInfo.orderId"
						class='bnt cancel'
						v-else-if="orderInfo.paid === true && orderInfo.refundStatus === 0 && orderInfo.type!==1 && type==='normal'">
						申请退款
					</navigator>
					<!-- #endif -->
					<view class='bnt bg-color' v-if="orderInfo.combinationId > 0" @tap='goJoinPink'>查看拼团</view>
					<navigator class='bnt cancel' v-if="orderInfo.deliveryType == 'express' && orderInfo.status >0"
						hover-class='none' :url="'/pages/users/goods_logistics/index?orderId='+ orderInfo.orderId">
						查看物流
					</navigator>
					<view class='bnt bg-color' v-if="orderInfo.status==1" @tap='confirmOrder'>确认收货</view>
					<view class='bnt cancel' v-if="orderInfo.status==3" @tap='delOrder'>删除订单</view>
					<view class='bnt bg-color' v-if="orderInfo.status==3 && orderInfo.type!==1" @tap='goOrderConfirm'>
						再次购买</view>
				</view>

			</view>
			<home></home>
			<payment :payMode='payMode' :pay_close="pay_close" @onChangeFun='onChangeFun' :order_id="pay_order_id"
				:totalPrice='totalPrice'></payment>
		</view>

		<!-- #ifdef MP -->
		<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
		<!-- #endif -->

		<uni-popup ref="lookGrtificatesPup" type="center">
			<view class="safeguardPup-wrap">

				<view class="safeguardPup-head safeguardPup-head1 dis">
					<view class="">

					</view>
					<view class="safeguardPup-head-center"></view>
					<view class="safeguardPup-head-right" @click="this.$refs.lookGrtificatesPup.close()">
						<image src="@/static/com/icon_close.png" mode=""></image>
					</view>
				</view>
				<view class="safeguardPup-msg dis">
					<view class="safeguardPup-msg-msg dis">
						<view class="safeguardPup-msg-msg-img">
							<image src="../../static/logo.png" mode=""></image>
						</view>
						<view class="safeguardPup-msg-msg-msg">
							<view class="safeguardPup-msg-msg-msg-name">张三</view>
							<view class="safeguardPup-msg-msg-msg-des">全部都是礼物</view>
						</view>
					</view>
					<view class="safeguardPup-msg-img">
						<image :src="orderInfo.certImage" mode=""></image>
					</view>
					<view class="safeguardPup-msg-msg1" @click="saveImg">
						保存图片
					</view>
				</view>

			</view>
		</uni-popup>
		<uni-popup ref="lookBigimgs" type="center" @maskClick="closeBigImg" @close="closeBigImg">
			<view class="" style="text-align: center;">

				<image style="width: 600rpx;height: 600rpx;" :src="qrcodeSrc" mode="aspectFit"></image>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getOrderDetail,
		orderTake,
		orderDel,
		orderCancel,
		qrcodeApi,
		
	} from '@/api/order.js';
	
	import {getOrderCert}from '@/api/togeterRich/order';
	import {
		openOrderRefundSubscribe
	} from '@/utils/SubscribeMessage.js';
	import home from '@/components/home';
	import payment from '@/components/payment';
	import orderGoods from "@/pagesB/fosterOrder/com/orderGoods";
	import ClipboardJS from "@/plugin/clipboard/clipboard.js";
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	// #ifdef MP
	import authorize from '@/components/Authorize';
	import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js'
	// #endif
	export default {
		components: {
			payment,
			home,
			orderGoods,
			// #ifdef MP
			authorize
			// #endif
		},
		data() {
			return {
				qrcodeSrc: '',
				// 二维码标识串
				qrcodeText: '',
				// 二维码尺寸
				// qrcodeSize: 136,
				codeImg: '',
				qrcodeSize: 100,
				order_id: '',
				evaluate: 0,
				cartInfo: [], //购物车产品
				orderInfo: {
					systemStore: {},
					pstatus: {}
				}, //订单详情
				system_store: {},
				isGoodsReturn: false, //是否为退款订单
				status: {}, //订单底部按钮状态
				isClose: false,
				payMode: [{
						name: "微信支付",
						icon: "icon-weixinzhifu",
						value: 'weixin',
						title: '微信快捷支付'
					},
					{
						name: "余额支付",
						icon: "icon-yuezhifu",
						value: 'yue',
						title: '可用余额:',
						number: 0
					},
				],
				pay_close: false,
				pay_order_id: '',
				totalPrice: '0',
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				id: 0, //订单id
				uniId: '',
				utils: this.$util,
				type: 'normal',
				infoType: 0,
				isLookBigImg: true
			};
		},
		computed: mapGetters(['isLogin', 'chatUrl', 'userInfo']),
		onLoad: function(options) {
			console.log('222')
			this.infoType = options.infoType
			console.log(options.infoType, 'options.infoType')
			options.type == undefined || options.type == null ? this.type = 'normal' : this.type = options.type;
			if (!options.order_id && !options.uniId) return this.$util.Tips({
				title: '缺少参数'
			}, {
				tab: 3,
				url: 1
			});
			this.$set(this, 'order_id', options.order_id);

		},
		onShow() {
			console.log('111')
			if (this.isLogin) {
				this.getOrderInfo();
				this.payMode[1].number = this.userInfo.nowMoney;
				this.$set(this, 'payMode', this.payMode);
			} else {
				toLogin();
			}
		},
		onHide: function() {
			this.isClose = true;
		},
		onReady: function() {
			// #ifdef H5
			this.$nextTick(function() {
				const clipboard = new ClipboardJS(".copy-data");
				clipboard.on("success", () => {
					this.$util.Tips({
						title: '复制成功'
					});
				});
			});
			// #endif

		},
		methods: {
			closeBigImg() {

				this.isLookBigImg = true
				this.checPickup()
			},
			lookBigImg() {
				this.isLookBigImg = false

				this.$refs.lookBigimgs.open()
			},
			goDk() {
				uni.navigateTo({
					url: "/pagesB/fosterOrder/landPlot/index?orderId=" + this.order_id
				})
			},
			saveImg() {
				let that = this
				uni.saveImageToPhotosAlbum({
					filePath: that.orderInfo.certImage,
					success: function() {
						console.log('save success');
					}
				});

			},
			lookGrtificates() {
				console.log(this.orderInfo,'this.orderInfothis.orderInfo')
				getOrderCert(this.orderInfo.id).then(res=>{
					console.log(res,'dddd')
				})
				
				this.$refs.lookGrtificatesPup.open()
			},
			goPage(url) {
				uni.navigateTo({
					url
				})
			},
			call(phone) {
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
			},
			openLocation(item) {
				uni.openLocation({
					latitude: Number(item.latitude), // 目标纬度
					longitude: Number(item.longitude), // 目标经度
					name: item.introduction,
					address: item.address + item.detailedAddress,
					success: function() {
						console.log('打开地图导航成功');
					},
					fail: function(err) {
						console.log('打开地图导航失败', err);
					}
				});
			},
			checPickup() {

				uQRCode.make({
					canvasId: 'qrcode',
					text: this.qrcodeText,
					size: this.qrcodeSize,
					margin: 10,
					success: res => {
						this.qrcodeSrc = res
						console.log('qrcodeSrc = ' + this.qrcodeSrc);
					},
					complete: () => {
						uni.hideLoading()
					}
				})

			},
			kefuClick() {
				location.href = this.chatUrl;
			},
			goGoodCall() {
				let self = this
				uni.navigateTo({
					url: `/pages/customer_list/index?orderId=${self.order_id}`
				})
			},
			openSubcribe: function(e) {
				let orderId = ''
				if (this.orderInfo.subOrderId) {
					orderId = this.orderInfo.subOrderId
				} else {
					orderId = this.orderInfo.orderId
				}
				// console.log(orderId, '这是撒很啊')
				// return;
				// '' + orderInfo
				// 	.orderId '/pages/users/goods_return/index?orderId=' + orderInfo.orderId)
				let page = e;
				uni.showLoading({
					title: '正在加载',
				})
				openOrderRefundSubscribe().then(res => {
					console.log(res, 'rree')
					uni.hideLoading();
					uni.navigateTo({
						url: '/pages/users/goods_return/index?orderId=' + orderId,
					});
				}).catch(() => {
					uni.hideLoading();
				});
			},
			/**
			 * 事件回调
			 * 
			 */
			onChangeFun: function(e) {
				let opt = e;
				let action = opt.action || null;
				let value = opt.value != undefined ? opt.value : null;
				(action && this[action]) && this[action](value);
			},
			/**
			 * 拨打电话
			 */
			makePhone: function() {
				uni.makePhoneCall({
					phoneNumber: this.system_store.phone
				})
			},
			/**
			 * 打开地图
			 * 
			 */
			showMaoLocation: function() {
				if (!this.system_store.latitude || !this.system_store.longitude) return this.$util.Tips({
					title: '缺少经纬度信息无法查看地图！'
				});
				uni.openLocation({
					latitude: parseFloat(this.system_store.latitude),
					longitude: parseFloat(this.system_store.longitude),
					scale: 8,
					name: this.system_store.name,
					address: this.system_store.address + this.system_store.detailedAddress,
					success: function() {

					},
				});
			},
			/**
			 * 关闭支付组件
			 * 
			 */
			payClose: function() {
				this.pay_close = false;
			},
			/**
			 * 打开支付组件
			 * 
			 */
			pay_open: function() {
				this.pay_close = true;
				this.pay_order_id = this.orderInfo.orderId;
				this.totalPrice = this.orderInfo.payPrice;
			},
			/**
			 * 支付成功回调
			 * 
			 */
			pay_complete: function() {
				this.pay_close = false;
				this.pay_order_id = '';
				this.getOrderInfo();
			},
			/**
			 * 支付失败回调
			 * 
			 */
			pay_fail: function() {
				this.pay_close = false;
				this.pay_order_id = '';
			},
			/**
			 * 登录授权回调
			 * 
			 */
			onLoadFun: function() {
				this.getOrderInfo();
			},
			/**
			 * 获取订单详细信息
			 * 
			 */
			getOrderInfo: function() {
				let that = this;
				uni.showLoading({
					title: "正在加载中"
				});
				getOrderDetail(that.order_id).then(res => {
					uni.hideLoading();
					that.$set(that, 'orderInfo', res.data);
					that.$set(that, 'evaluate', res.data.status == 2 ? 2 : 0);
					that.$set(that, 'system_store', res.data.systemStore);
					that.$set(that, 'id', res.data.id);
					that.$set(that, 'cartInfo', res.data.orderInfoList);
					if (res.data.refundStatus != 0) {
						that.isGoodsReturn = true;
					};
					if (that.orderInfo.shippingType == 2) {
						this.qrcodeText = res.data.verifyCode
					}
					if (that.orderInfo.refundStatus > 0) {
						uni.setNavigationBarColor({
							frontColor: '#ffffff',
							backgroundColor: '#666666'
						})
					}
					this.checPickup()
				}).catch(err => {
					uni.hideLoading();
					that.$util.Tips({
						title: err
					});
				});
			},
			/**
			 * 
			 * 生成二维码
			 */
			markCode(text) {
				qrcodeApi({
					height: '145',
					text: text,
					width: '145'
				}).then(res => {
					this.codeImg = res.data.code
				});
			},
			/**
			 * 
			 * 剪切订单号
			 */
			// #ifndef H5
			copy: function(id) {
				let that = this;
				uni.setClipboardData({
					data: id
				});
			},
			// #endif
			/**
			 * 打电话
			 */
			goTel: function() {
				uni.makePhoneCall({
					phoneNumber: this.orderInfo.deliveryId
				})
			},
			/**
			 * 设置底部按钮
			 * 
			 */
			getOrderStatus: function() {
				let orderInfo = this.orderInfo || {},
					_status = orderInfo.pstatus || {
						type: 0
					},
					status = {};
				let type = parseInt(_status.type),
					delivery_type = orderInfo.deliveryType,
					seckill_id = orderInfo.seckillId ? parseInt(orderInfo.seckillId) : 0,
					bargain_id = orderInfo.bargainId ? parseInt(orderInfo.bargainId) : 0,
					combination_id = orderInfo.combinationId ? parseInt(orderInfo.combinationId) : 0;
				status = {
					type: type == 9 ? -9 : type,
					class_status: 0
				};
				if (type == 1 && combination_id > 0) status.class_status = 1; //查看拼团
				if (type == 2 && delivery_type == 'express') status.class_status = 2; //查看物流
				if (type == 2) status.class_status = 3; //确认收货
				if (type == 4 || type == 0) status.class_status = 4; //删除订单
				if (!seckill_id && !bargain_id && !combination_id && (type == 3 || type == 4)) status.class_status =
					5; //再次购买
				this.$set(this, 'status', status);
			},
			/**
			 * 去拼团详情
			 * 
			 */
			goJoinPink: function() {
				uni.navigateTo({
					url: '/pages/activity/goods_combination_status/index?id=' + this.orderInfo.pinkId,
				});
			},
			/**
			 * 再此购买
			 * 
			 */
			goOrderConfirm: function() {
				this.$Order.getPreOrder('', "again", [{
					orderNo: this.order_id
				}]);
			},
			confirmOrder: function() {
				let that = this;
				uni.showModal({
					title: '确认收货',
					content: '为保障权益，请收到货确认无误后，再确认收货',
					success: function(res) {
						if (res.confirm) {
							orderTake(that.id).then(res => {
								return that.$util.Tips({
									title: '操作成功',
									icon: 'success'
								}, function() {
									that.getOrderInfo();
								});
							}).catch(err => {
								return that.$util.Tips({
									title: err
								});
							})
						}
					}
				})
			},
			/**
			 * 
			 * 删除订单
			 */
			delOrder: function() {
				let that = this;
				orderDel(this.id).then(res => {
					return that.$util.Tips({
						title: '删除成功',
						icon: 'success'
					}, {
						tab: 3,
						url: 1
					});
				}).catch(err => {
					return that.$util.Tips({
						title: err
					});
				});
			},
			cancelOrder() {
				let self = this
				uni.showModal({
					title: '提示',
					content: '确认取消该订单?',
					success: function(res) {
						if (res.confirm) {
							orderCancel(self.orderInfo.id)
								.then((data) => {
									self.$util.Tips({
										title: '取消成功'
									}, {
										tab: 3
									})
								})
								.catch(() => {
									self.$util.Tips({
										title: err
									})
									self.getDetail();
								});
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
		}
	}
</script>
<style scoped lang="scss">
	@import '@/pagesB/fosterOrder/com/obtainable.css';

	.safeguardPup-wrap {
		.safeguardPup-msg {
			width: 80%;

			margin: 30rpx auto;
			justify-content: space-between;
			font-size: 28rpx;
			flex-direction: column;
			text-align: center;

			.safeguardPup-msg-msg1 {
				text-align: center;
				margin: 30rpx 0;
				color: $maincolor;
			}

			.safeguardPup-msg-msg {
				text-align: center;

				.safeguardPup-msg-msg-img {
					border-radius: 50%;
					width: 106rpx;
					height: 106rpx;

					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}

				.safeguardPup-msg-msg-msg {
					margin-left: 20rpx;

					.safeguardPup-msg-msg-msg-name {
						font-size: 36rpx;
						color: #000;
					}

					.safeguardPup-msg-msg-msg-des {
						font-size: 24rpx;
						color: #999;
					}
				}

			}

			.safeguardPup-msg-img {
				width: 100%;
				height: 400rpx;
				margin: 30rpx auto;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.safeguardPup-head1 {
			justify-content: space-between;
			padding: 36rpx 36rpx 0 36rpx;

			image {
				width: 50rpx;
				height: 50rpx;
			}
		}


		width: 680rpx;

		background: #fff;
		border-radius: 20rpx;
	}

	.wrapp {
		padding: 20rpx 0;
		background: #fff;
		margin: 20rpx 0;
	}

	.block_41 {
		margin-bottom: 0rpx;
		border-bottom: 1rpx solid #f5f5f5;

		.text_6 {
			justify-content: space-between;
		}
	}

	.titiles {

		margin-left: 20rpx;

		.titiles-bom {
			font-size: 22rpx;
			color: #999;
			margin-top: 20rpx;
		}

		.titiles-up {
			justify-content: space-between;
			align-items: center;

			.titiles-up-left {
				font-size: 26rpx;
				color: #333;
				padding-left: 20rpx;
				border-left: 7rpx solid;

				border-left: 6rpx solid $maincolor;
			}

			.titiles-up-right {
				width: 150rpx;
				text-align: center;
				height: 54rpx;
				background: $maincolor;
				border-radius: 60rpx;
				margin-right: 20rpx;
				opacity: 1;
				line-height: 54rpx;
				color: #fff;
			}
		}
	}

	.index-coupon {
		width: 100%;
		/* height: 200rpx; */
		background: #fff;
		padding: 20rpx 0;

		.index-coupon-view {
			// width: 80%;
			margin: 20rpx auto;

		}

		.index-coupon-msg {
			background-size: 100% 100%;
			display: inline-block;
			height: 180rpx;
			border-radius: 10rpx;
			opacity: 1;
			padding: 0 25rpx;
			border: 2rpx solid #d1d1d1;
			margin: 10px;


			.index-coupon-msg-wrap {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 100%;
				/* width: 510rpx; */
				padding-right: 20rpx;

				.index-coupon-msg-bom {
					width: 30rpx;
					font-size: 28rpx;
					color: $maincolor;
					padding: 10rpx 0;
					writing-mode: vertical-lr;
					/*从左向右 从右向左是 writing-mode: vertical-rl;*/
					writing-mode: tb-lr;
					/*IE浏览器的从左向右 从右向左是 writing-mode: tb-rl；*/
				}

				.index-coupon-msg-center {
					margin-left: 20rpx;
					font-size: 28rpx;
				
					color: #333;

					.index-coupon-msg-center-up {
						    width: 140rpx;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
						word-break: break-all;

					}

					.index-coupon-msg-center-bom {

						opacity: 1;

						margin-top: 20rpx;

					}
				}

				.index-coupon-msg-left {
					width: 100rpx;
					height: 100rpx;
					margin: 6rpx auto;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

		}
	}

	.selfInfo {
		background: #fff;

		margin: 20rpx 0;
		padding: 30rpx;

		.selfInfo-wrap {
			width: 100%;

			.selfInfo-msg {
				.selfInfo-msg-lefts {
					align-items: center;
					justify-content: center;
					margin: 20rpx 0;

					image {
						width: 50rpx;
						height: 50rpx;
						margin-right: 20rpx;

					}
				}

				.selfInfo-msg-ritght {

					text-align: center;
					margin: 0 auto;

					.selfInfo-msg-ritght1 {
						width: 215rpx;
						height: 215rpx;
						margin: 0 auto;

						image {
							width: 100%;
							height: 100%;
						}
					}

					.selfInfo-msg-ritght2 {
						font-size: 28rpx;
					}
				}

				.selfInfo-msg-left {

					width: 50%;

					font-size: 28rpx;
					color: #333;

					.selfInfo-msg-left1 {
						color: #F05208;
					}

					.selfInfo-msg-left1 {}

					.selfInfo-msg-left3 {
						font-size: 26rpx;
					}

					.selfInfo-msg-left4 {
						font-size: 26rpx;
					}
				}

				.selfInfo-msg-right {
					width: 50%;
				}
			}
		}

	}

	.shuoming {
		width: 32rpx;
		height: 32rpx;
	}

	.goodCall {
		color: $theme-color;
		text-align: center;
		width: 100%;
		height: 86rpx;
		padding: 0 35rpx;
		border-bottom: 1rpx solid #eee;
		font-size: 30rpx;
		line-height: 86rpx;
		background: #fff;

		.icon-kefu {
			font-size: 36rpx;
			margin-right: 15rpx;
		}

		/* #ifdef MP */
		button {
			display: flex;
			align-items: center;
			justify-content: center;
			height: 86rpx;
			font-size: 30rpx;
			color: $theme-color;
		}

		/* #endif */
	}

	.order-details .header {
		// height: 250rpx;
		padding: 20rpx;
	}

	.order-details .header.on {
		background-color: #666 !important;
	}

	.order-details .header .pictrue {
		width: 110rpx;
		height: 110rpx;
	}

	.order-details .header .pictrue image {
		width: 100%;
		height: 100%;
	}

	.order-details .header .data {
		color: rgba(255, 255, 255, 0.8);
		font-size: 24rpx;
		margin-left: 27rpx;
	}

	.order-details .header .data.on {
		margin-left: 0;
	}

	.order-details .header .data .state {
		font-size: 30rpx;
		font-weight: bold;
		color: #fff;
		margin-bottom: 7rpx;
	}

	.order-details .header .data .time {
		margin-left: 20rpx;
	}

	.picTxt {
		height: 150rpx;
	}

	.order-details .nav {
		background-color: #fff;
		font-size: 26rpx;
		color: #282828;
		padding: 27rpx 0;
		width: 100%;
		border-radius: 14rpx;
		// margin: -100rpx auto 0 auto;
	}

	.order-details .nav .navCon {
		padding: 0 40rpx;
	}

	.order-details .nav .on {
		color: $theme-color;
	}

	.order-details .nav .progress {
		padding: 0 65rpx;
		margin-top: 10rpx;
	}

	.order-details .nav .progress .line {
		width: 100rpx;
		height: 2rpx;
		background-color: #939390;
	}

	.order-details .nav .progress .iconfont {
		font-size: 25rpx;
		color: #939390;
		margin-top: -2rpx;
	}

	.order-details .address {
		font-size: 26rpx;
		color: #868686;
		background-color: #fff;
		margin-top: 15rpx;
		padding: 30rpx 24rpx;
	}

	.order-details .address .name {
		font-size: 30rpx;
		color: #282828;
		margin-bottom: 15rpx;
	}

	.order-details .address .name .phone {
		margin-left: 40rpx;
	}

	.order-details .line {
		width: 100%;
		height: 3rpx;
	}

	.order-details .line image {
		width: 100%;
		height: 100%;
		display: block;
	}

	.order-details .wrapper {
		background-color: #fff;
		margin-top: 12rpx;
		padding: 30rpx 24rpx;
	}

	.order-details .wrapper .item {
		font-size: 28rpx;
		color: #282828;
	}

	.order-details .wrapper .item~.item {
		margin-top: 20rpx;
	}

	.order-details .wrapper .item .conter {
		color: #868686;
		// width: 490rpx;
		text-align: right;
	}

	.order-details .wrapper .item .conter .copy {
		font-size: 20rpx;
		color: #333;
		border-radius: 20rpx;
		border: 1rpx solid #666;
		padding: 3rpx 15rpx;
		margin-left: 24rpx;
	}

	.order-details .wrapper .actualPay {
		border-top: 1rpx solid #eee;
		margin-top: 30rpx;
		padding-top: 30rpx;
	}

	.order-details .wrapper .actualPay .money {
		font-weight: bold;
		font-size: 30rpx;
	}

	.order-details .footer {
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		background-color: #fff;
		padding: 0 25rpx;
		box-sizing: border-box;
	}

	.order-details .footer .bnt {
		width: 158rpx;
		height: 54rpx;
		text-align: center;
		line-height: 54rpx;
		border-radius: 50rpx;
		color: #fff;
		font-size: 27rpx;
	}

	.order-details .footer .bnt.cancel {
		color: #aaa;
		border: 1rpx solid #ddd;
	}

	.order-details .footer .bnt~.bnt {
		margin-left: 18rpx;
	}

	.order-details .writeOff {
		background-color: #fff;
		margin-top: 15rpx;
		padding-bottom: 50rpx;
	}

	.order-details .writeOff .title {
		font-size: 30rpx;
		color: #282828;
		height: 87rpx;
		border-bottom: 1px solid #f0f0f0;
		padding: 0 24rpx;
		line-height: 87rpx;
	}

	.order-details .writeOff .grayBg {
		background-color: #f2f5f7;
		width: 590rpx;
		height: 384rpx;
		border-radius: 20rpx 20rpx 0 0;
		margin: 50rpx auto 0 auto;
		padding-top: 55rpx;
	}

	.order-details .writeOff .grayBg .pictrue {
		width: 290rpx;
		height: 290rpx;
		margin: 0 auto;
	}

	.order-details .writeOff .grayBg .pictrue image {
		width: 100%;
		height: 100%;
		display: block;
	}

	.order-details .writeOff .gear {
		width: 590rpx;
		height: 30rpx;
		margin: 0 auto;
	}

	.order-details .writeOff .gear image {
		width: 100%;
		height: 100%;
		display: block;
	}

	.order-details .writeOff .num {
		background-color: #f0c34c;
		width: 590rpx;
		height: 84rpx;
		color: #282828;
		font-size: 48rpx;
		margin: 0 auto;
		border-radius: 0 0 20rpx 20rpx;
		text-align: center;
		padding-top: 4rpx;
	}

	.order-details .writeOff .rules {
		margin: 46rpx 30rpx 0 30rpx;
		border-top: 1px solid #f0f0f0;
		padding-top: 10rpx;
	}

	.order-details .writeOff .rules .item {
		margin-top: 20rpx;
	}

	.order-details .writeOff .rules .item .rulesTitle {
		font-size: 28rpx;
		color: #282828;
	}

	.order-details .writeOff .rules .item .rulesTitle .iconfont {
		font-size: 30rpx;
		color: #333;
		margin-right: 8rpx;
		margin-top: 5rpx;
	}

	.order-details .writeOff .rules .item .info {
		font-size: 28rpx;
		color: #999;
		margin-top: 7rpx;
	}

	.order-details .writeOff .rules .item .info .time {
		margin-left: 20rpx;
	}

	.order-details .map {
		height: 86rpx;
		font-size: 30rpx;
		color: #282828;
		line-height: 86rpx;
		border-bottom: 1px solid #f0f0f0;
		margin-top: 15rpx;
		background-color: #fff;
		padding: 0 24rpx;
	}

	.order-details .map .place {
		font-size: 26rpx;
		width: 176rpx;
		height: 50rpx;
		border-radius: 25rpx;
		line-height: 50rpx;
		text-align: center;
	}

	.order-details .map .place .iconfont {
		font-size: 27rpx;
		height: 27rpx;
		line-height: 27rpx;
		margin: 2rpx 3rpx 0 0;
	}

	.order-details .address .name .iconfont {
		font-size: 34rpx;
		margin-left: 10rpx;
	}

	.refund {
		padding: 0 !important;
		margin-top: 15rpx;
		background-color: #fff;

		.title {
			display: flex;
			align-items: center;
			font-size: 30rpx;
			color: #333;
			height: 86rpx;
			border-bottom: 1px solid #f5f5f5;
			font-weight: 400;
			padding: 0 24rpx;

			image {
				width: 32rpx;
				height: 32rpx;
				margin-right: 10rpx;
			}
		}

		.con {
			font-size: 25rpx;
			color: #666666;
			padding: 30rpx 24rpx;
		}
	}
</style>

<style>
	.qs-btn {
		width: auto;
		height: 60rpx;
		text-align: center;
		line-height: 60rpx;
		border-radius: 50rpx;
		color: #fff;
		font-size: 27rpx;
		padding: 0 3%;
		color: #aaa;
		border: 1px solid #ddd;
		margin-right: 20rpx;
	}
</style>